package com.hilaver.dzmis.order;

import java.util.Comparator;
import java.util.Date;
import java.util.Set;
import java.util.TreeSet;

import com.hilaver.dzmis.basicinfo.BiFactory;
import com.hilaver.dzmis.basicinfo.BiFranceCustomerEshop;
import com.hilaver.dzmis.product.ProductIdentification;

public class OrderProduct {
	private Integer id;
	private Date createDate;
	private Date departureDate;
	private String ctOrderType;
	private String isConfirmed;
	private Date confirmedDate;
	private String orderNumber;
	private String ctSeasonNumber;
	private Integer quantity;
	private String isEshop;
	private BiFranceCustomerEshop biFranceCustomerEshop;
	private ProductIdentification productIdentification;
	private Set<OrderProductItem> orderProductItems = new TreeSet<OrderProductItem>(new Foo());

	class Foo implements Comparator {
		public int compare(Object s1, Object s2) {
			return 1;
		}
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public Date getDepartureDate() {
		return departureDate;
	}
	public void setDepartureDate(Date departureDate) {
		this.departureDate = departureDate;
	}
	public String getCtOrderType() {
		return ctOrderType;
	}
	public void setCtOrderType(String ctOrderType) {
		this.ctOrderType = ctOrderType;
	}
	public String getIsConfirmed() {
		return isConfirmed;
	}
	public void setIsConfirmed(String isConfirmed) {
		this.isConfirmed = isConfirmed;
	}
	public Date getConfirmedDate() {
		return confirmedDate;
	}
	public void setConfirmedDate(Date confirmedDate) {
		this.confirmedDate = confirmedDate;
	}
	public String getOrderNumber() {
		return orderNumber;
	}
	public void setOrderNumber(String orderNumber) {
		this.orderNumber = orderNumber;
	}
	public String getCtSeasonNumber() {
		return ctSeasonNumber;
	}
	public void setCtSeasonNumber(String ctSeasonNumber) {
		this.ctSeasonNumber = ctSeasonNumber;
	}
	public Integer getQuantity() {
		return quantity;
	}
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}
	public ProductIdentification getProductIdentification() {
		return productIdentification;
	}
	public void setProductIdentification(ProductIdentification productIdentification) {
		this.productIdentification = productIdentification;
	}
	public Set getOrderProductItems() {
		return orderProductItems;
	}
	public void setOrderProductItems(Set orderProductItems) {
		this.orderProductItems = orderProductItems;
	}
	
	public String getIsEshop() {
		return isEshop;
	}
	public void setIsEshop(String isEshop) {
		this.isEshop = isEshop;
	}
	public BiFranceCustomerEshop getBiFranceCustomerEshop() {
		return biFranceCustomerEshop;
	}
	public void setBiFranceCustomerEshop(BiFranceCustomerEshop biFranceCustomerEshop) {
		this.biFranceCustomerEshop = biFranceCustomerEshop;
	}
	public Integer getTotal(Integer sizeIndex, String variant){
		Integer total = 0;
				
		if("all".equals(variant)){
			for (OrderProductItem opi : orderProductItems) {
				total += opi.getSizeTotal(sizeIndex);
			}
		}else{
			for (OrderProductItem opi : orderProductItems) {
				if(variant.equals(opi.getVariant())){
					total += opi.getSizeTotal(sizeIndex);
				}
			}
		}
		
		return total;
	}
	@Override
	public String toString() {
		return this.orderNumber + this.productIdentification.toString();
	}
}
